<template>
  <div class="home">
    <!-- header -->
    <Head />
    <Banner />
    <Nav />
    <!-- /header -->

    <!-- main -->
    <div class="main">
      <div class="middle">
        <!-- 天气提示 -->
        <div class="weather">
          <span class="rili">
            <img src="../assets/image/rili.png" alt />
          </span>
          <span>今天是：</span>
          <!-- 接口数据 -->
          <span>{{ timer | dateFormat2 }}</span>
        </div>

        <div class="first">
          <!-- 工作室概况 -->
          <div class="gzs">
            <!-- 标题 -->
            <div class="title">
              <h3>工作室概况</h3>
            </div>
            <!-- 内容 -->
            <div class="content">
              <p>{{ gzsjs.gzsdesc }}</p>
              <a
                style="color: #d37b4c; font-size: 12px"
                @click="goDetail('studioIntro')"
                >【详情】</a
              >
            </div>
          </div>
          <!-- 最新动态 -->
          <div class="newActivity">
            <!-- 标题 -->
            <div class="title">
              <h3>最新动态</h3>
              <h3 @click="goDetail('newActivity')">更多>></h3>
            </div>
            <!-- 内容 -->
            <div class="content">
              <div class="medial">
                <!-- 轮播 -->
                <Swipernews
                  ref="swipers"
                  @fatherMethod="fatherMethod()"
                ></Swipernews>
                <!-- <img src="" alt=""> -->
              </div>
              <!-- <div class="mediar">
                <a
                  v-for="(item ,index) in zxdt"
                  :key="index"
                  @click="gonewActivityDetail(item.id)"
                >{{item.title}}</a>
              </div>-->
            </div>
          </div>
          <!-- 通知公告 -->
          <div class="notice">
            <!-- 标题 -->
            <div class="title">
              <h3>通知公告</h3>
              <h3 @click="goDetail('notice')">更多>></h3>
            </div>
            <!-- 内容 -->
            <div class="noticecon">
              <a
                v-for="(item, index) in tzgg"
                :key="index"
                @click="goNoticeDetail(item.id)"
                >{{ item.title }}</a
              >
            </div>
          </div>
        </div>

        <!-- 传承之路-->
        <Swipercczl></Swipercczl>

        <div class="third">
          <!-- 临床医案 -->
          <div class="medrecord">
            <!-- 标题 -->
            <div class="title">
              <h3>临床医案</h3>
              <h3 @click="goDetail('medicalrecord')">更多>></h3>
            </div>
            <!-- 内容 -->
            <div class="content">
              <img src="../assets/image/中医.jpg" alt />
              <div class="left">
                <a
                  v-for="(item, index) in lcya"
                  :key="index"
                  @click="gomedicalrecordDetail(item.id)"
                  >{{ item.title }}</a
                >
              </div>
            </div>
          </div>
          <!-- 出诊表 -->
          <div class="visitForm">
            <!-- 标题 -->
            <div class="title">
              <h3>出诊表</h3>
              <h3 @click="goDetail('heritageroad')">更多>></h3>
            </div>
            <!-- 内容 -->
            <div style="height: 249px; overflow: scroll">
              <table class="table">
                <thead>
                  <tr>
                    <th>姓名</th>
                    <th>职称</th>
                    <th>出诊时间</th>
                  </tr>
                </thead>
                <tbody>
                  <tr v-for="(item, index) in cczl" :key="item.id">
                    <td>
                      <a @click="goHeritageRoad(item.id)">{{ item.name }}</a>
                    </td>
                    <td>{{ item.zjzc }}</td>
                    <td>{{ item.mzsj }}</td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
        </div>
        <div class="forth">
          <!-- 获奖情况 -->
          <div class="awards">
            <!-- 标题 -->
            <div class="title">
              <h3>获奖情况</h3>
              <h3 @click="goDetail('awards')">更多>></h3>
            </div>
            <!-- 内容 -->
            <div class="awardpic">
              <a
                v-for="(item, index) in ryzs"
                :key="index"
                @click="goAwardsDetail(item.id)"
              >
                <img :src="item.zpurl" alt />
                <span>{{ item.title }}</span>
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- /main -->
    <!-- 地图 -->
    <div class="map">
      <div class="content">
        <div class="maple">
          <h3 @click="getMenulist">范永升全国名中医工作室</h3>
          <div>
            <img src="../assets/image/电话.png" alt />
            <p>总机：0571-85267000</p>
          </div>
          <div>
            <img src="../assets/image/急救.png" alt />
            <p>急救：120</p>
          </div>
          <div>
            <img src="../assets/image/地址.png" alt />
            <p>地址：浙江省杭州市潮王路318号（310005）</p>
          </div>
        </div>
        <!--地图容器-->
        <div id="allmap" ref="allmap"></div>
      </div>
    </div>
    <!-- footer -->
    <Footer></Footer>
    <!-- /footer -->
  </div>
</template>

<script>
// import BMap from "BMap";
// @ is an alias to /src
import Head from "@/components/Head.vue";
import Banner from "@/components/Banner.vue";
import Nav from "@/components/Nav.vue";
import Footer from "@/components/Footer.vue";
import Swipernews from "@/components/Swipernews.vue";
import Swipercczl from "@/components/Swipercczl.vue";

export default {
  name: "Home",
  components: {
    Head,
    Banner,
    Nav,
    Footer,
    Swipernews,
    Swipercczl,
  },
  data() {
    return {
      gzsjs: [], //工作室概况
      zxdt: [], // 最新动态
      tzgg: [], // 通知公告
      cczl: [], // 传承之路
      lcya: [], // 临床医案
      // 出诊表
      ryzs: [], // 获奖情况
      timer: new Date(),
      isMini: false,
    };
  },
  created() {
    this.getMenulist();
  },
  mounted() {
    this.ready();
  },

  methods: {
    // 地图
    ready() {
      // 百度地图API功能
      var map = new BMapGL.Map("allmap");
      // 坐标
      var point = new BMapGL.Point(120.154863, 30.290917);
      map.centerAndZoom(point, 15);

      // map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
      map.setHeading(64.5);
      // map.setTilt(73);
      var marker = new BMapGL.Marker(point); // 创建标注
      map.addOverlay(marker); // 将标注添加到地图中
      var opts = {
        width: 200, // 信息窗口宽度
        height: 30, // 信息窗口高度
        title: "范永升全国名中医工作室", // 信息窗口标题
        message: "范永升全国名中医工作室",
      };
      var infoWindow = new BMapGL.InfoWindow(
        "地址：浙江省杭州市潮王路318号（310005）",
        opts
      ); // 创建信息窗口对象

      map.openInfoWindow(infoWindow, point); //开启信息窗口
      marker.addEventListener("click", function () {
        map.openInfoWindow(infoWindow, point); //开启信息窗口
      });
    },
    //首页接口
    getMenulist() {
      this.$axios
        .get("TCM/GetFirstPage")
        .then((res) => {
          if (res.status == 200) {
            // console.log(res.data);
            this.gzsjs = res.data.gzsjs[0];
            this.gzsjs.gzsdesc = this.removeHTMLTag(this.gzsjs.gzsdesc);
            this.zxdt = res.data.zxdt;
            this.tzgg = res.data.tzgg;
            this.cczl = res.data.cczl;
            this.lcya = res.data.lcya;
            this.ryzs = res.data.ryzs;
            // console.log(this.cczl);
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 点击详情跳转到工作室介绍
    goDetail(r) {
      this.$router.push({ path: "/" + r });
      // if (r == "studioIntro") {
      //   this.addCount(id, "awardsDetail", "8");
      // }
    },
    // 跳转到获奖情况详情页
    goAwardsDetail(id) {
      // this.$router.push({ path: `/awardsDetail/${id}` });
      // 点击数加1
      this.addCount(id, "awardsDetail", "8");
    },
    // 跳转到通知公告详情页
    goNoticeDetail(id) {
      this.addCount(id, "noticeDetail", "2");
    },
    // 跳转到传承之路详情页
    goHeritageRoad(id) {
      this.addCount(id, "heritageroadDetail", "4");
    },
    // 跳转到最新动态详情页
    gonewActivityDetail(id) {
      this.addCount(id, "newActivityDetail", "1");
    },
    // 跳转到临床医案详情页
    gomedicalrecordDetail(id) {
      this.addCount(id, "medicalrecordDetail", "3");
    },
    getHeight() {
      let height = window.innerHeight;
      if (height > 1200) {
        this.isMini = true;
      }
    },
    // 增加点击量接口
    addCount(id, url, type) {
      let queryData = {
        type,
        id,
      };
      this.$axios
        .post("UpdTCM/addcount", queryData)
        .then((res) => {
          if (res.status == 200) {
            this.$router.push({ path: `/${url}/${id}` });
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    removeHTMLTag(str) {
      str = str.replace(/<\/?[^>]*>/g, ""); //去除HTML tag
      str = str.replace(/[ | ]*\n/g, "\n"); //去除行尾空白
      //str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
      str = str.replace(/ /gi, ""); //去掉
      return str;
    },
    fatherMethod() {
      // this.$refs.swipers.goDetail()
    },
  },
};
</script>

<style lang="less" scoped>
@media screen and (max-width: 1200px) {
  .main {
    padding: 0 !important;

    // width: 800px !important;
    // .map.content[data-v-fae5bece] {/
  }
  .map .content[data-v-fae5bece] {
    padding: 20px !important;
  }
}
.home {
  width: 100%;
  //  width: 1200px;
  background: url("../assets/image/diwen.jpg") repeat-y;
  // height: 100%;
  .main {
    // width: 1200px;
    margin: 0 auto;
    padding: 0 25%;
    // height: 1000px;
    height: 100%;

    .middle {
      height: 100%;
      background-color: #ffffff;
      padding: 0 10px 10px;
      box-sizing: border-box;
      .weather {
        padding: 10px 0;
        .rili {
          img {
            width: 18px;
            height: 18px;
            margin-right: 5px;
            vertical-align: middle;
          }
        }
      }
      // 第一行
      .first {
        // width: 100%;
        height: 310px;
        display: flex;
        justify-content: center;
        //工作室概况
        .gzs {
          height: 310px;
          flex: 1;
          // width: 280px !important;
          // height: 400px;
          box-sizing: border-box;
          border: 0.5px solid #ebe4d9;
          border-top: none;
          // padding-bottom: 10px;
          text-overflow: ellipsis;
          overflow: hidden;
          p {
            // width: 280px;
            height: 230px;
            overflow: hidden;
            text-overflow: ellipsis;
            margin-bottom: 0;
            font-size: 14px;
            padding: 5px 10px 0;
            line-height: 180%;
            box-sizing: border-box;
            font-weight: 500;
            text-indent: 2em;
            letter-spacing: 1px;
          }
          a {
            cursor: pointer;
          }
          a:hover {
            color: red !important;
          }
        }
        //最新动态
        .newActivity {
          margin: 0 10px;
          // width: 660px;
          flex: 2;
          overflow: hidden;
          box-sizing: border-box;
          border: 0.5px solid #ebe4d9;
          border-top: none;
          padding-bottom: 10px;
          .content {
            display: flex;
            justify-content: space-between;
            padding: 10px 0;
            box-sizing: border-box;
            .medial {
              flex: 1;
              // float: left;
              // width: 280px;
              height: 230px;
              // background-color: #c9c9c9;
              cursor: pointer;
            }
            .mediar {
              flex: 1.5;
              // float: left;
              // width: 300px;
              height: 230px;
              overflow: hidden;
              margin: 0 0 0 10px;
              overflow-y: hidden;
              a {
                display: block;
                cursor: pointer;
                // width: 220px;
                font-size: 14px;
                font-weight: 500;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                color: #2c3e50;
                line-height: 180%;
              }
              a:before {
                display: inline-block;
                content: "●"; //'\25CF'
                padding-right: 10px;
                color: #7b4224;
                font-size: 6px;
              }
              a:hover {
                color: red;
              }
            }
          }
        }
        // 通知道公告
        .notice {
          flex: 1;
          // width: 250px;
          height: 310px;
          overflow: hidden;
          // box-sizing: border-box;
          border: 0.5px solid #ebe4d9;
          border-top: none;
          .noticecon {
            height: 230px;
            padding: 25px 10px;
            // box-sizing: border-box;
            overflow-y: hidden;
            a {
              display: block;
              width: 100%;
              font-size: 14px;
              font-weight: 500;
              cursor: pointer;
              overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
              color: #2c3e50;
              line-height: 180%;
            }
            a:before {
              display: inline-block;
              content: "●"; //'\25CF'
              padding-right: 10px;
              color: #7b4224;
              font-size: 6px;
            }
            a:hover {
              color: red !important;
            }
          }
        }
      }
      //第三行
      .third {
        margin-top: 20px;
        display: flex;
        justify-content: center;
        height: 285px;
        overflow: hidden;
        .medrecord {
          flex: 1;
          margin-right: 10px;
          border: 0.5px solid #ebe4d9;
          border-top: none;
          .content {
            display: flex;
            justify-content: space-between;
            img {
              // flex: 1;
              width: 45%;
              max-width: 150px;
              height: 30%;
              margin-top: 30px;
              margin-left: 5px;
              margin-right: 30px;
              vertical-align: middle;
            }
            .left {
              // flex: 1;
              // background-color: #000;
              // width: 100%;
              height: 200px;
              overflow: hidden;
              padding-top: 10px;
              box-sizing: border-box;
              a {
                margin-top: 10px;
                display: block;
                width: 95%;
                font-size: 14px;
                cursor: pointer;
                // width: 180px;
                white-space: nowrap;
                text-overflow: ellipsis;
                overflow: hidden;
              }
              // a:nth-child(odd) {
              //   margin-right: 10px;
              // }
              a:before {
                display: inline-block;
                content: "●"; //'\25CF'
                padding-right: 10px;
                color: #7b4224;
                font-size: 6px;
              }
              a:hover {
                color: red;
              }
            }
          }
        }
        .visitForm {
          // flex: 1.8;
          width: 410px !important;
          border: 0.5px solid #ebe4d9;
          border-top: none;
          .table {
            font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
            font-size: 14px;
            background: #fff;
            width: 410px !important;
            border-collapse: collapse;

            th {
              font-size: 14px;
              font-weight: bold;
              padding: 12px 8px;
            }
            td {
              font-size: 14px;
              font-weight: 500;
              overflow: hidden;
              flex-wrap: nowrap;
            }
            td:nth-child(1) {
              width: 30px;
            }
            td:nth-child(2) {
              width: 40px;
            }
            td:nth-child(3) {
              width: 120px;
            }
            tbody tr {
              height: 32px;
              line-height: 32px;
              td a {
                color: #765200;
                cursor: pointer;
              }
              td a:hover {
                color: red;
              }
            }
            tbody tr:nth-child(odd) {
              background-color: #ede7de;
            }
            tr {
              text-align: center;
            }
            // tr:hover td {
            //   background: #d0dafd;
            //   color: #339;
            // }
          }
        }
      }
      // 第四行
      .forth {
        margin-top: 20px;
        height: 210px;
        border: 0.5px solid #ebe4d9;
        border-top: none;
        box-sizing: border-box;
        .awardpic {
          padding: 20px 10px;
          height: 160px;
          // width: 1200px;
          display: flex;
          justify-content: space-between;
          overflow: hidden;
          text-align: center;
          a {
            // flex: 1;
            display: block;
            height: 140px;
            padding: 0 30px;
            width: 135px;
            cursor: pointer;
            img {
              // width: 100%;
              height: 100px;
            }
            span {
              padding-top: 10px;
              display: block;
              font-size: 12px;
            }
            span:hover {
              color: red;
            }
          }
        }
      }
    }
  }
  .map {
    margin-top: 40px;
    height: 340px;
    background: url("../assets/image/mapbg.jpg") no-repeat;
    overflow: hidden;
    .content {
      margin: 0 auto;
      padding: 38px 25% 20px;
      display: flex;
      justify-content: space-between;
      .maple {
        width: 430px;
        h3 {
          font-size: 30px;
          font-weight: 700;
          color: #7a4224;
        }
        div {
          display: flex;
          justify-content: flex-start;
          align-items: center;
          img {
            width: 20px;
            height: 20px;
            margin-right: 25px;
          }
          p {
            font-size: 18px;
            font-weight: 500;
            color: #7a4224;
          }
        }
      }
      #allmap {
        // width: 500px;
        flex: 1;
        height: 270px;
        // border: 2px solid #fff;
        background-color: #000;
      }
    }
  }
  .bdd {
    border: 0.5px solid #ebe4d9;
    border-top: none;
  }
}
</style>
